package com.liwei.innerclass;

/**
 * 从多层嵌套类中访问访问外部类的成员. “.new“语法产生了正确的作用域
 */
public class A {
	private int a;

	public A(int a) {
		this.a = a;
	}

	private void f() {
		System.out.println("f() a=" + a);
	}

	class B {
		private int b;

		public B(int b) {
			this.b = b;
		}

		private void g() {
			System.out.println("g() a=" + a + " b=" + b);
		}

		class C {
			private int c;

			public C(int c) {
				this.c = c;
			}

			void h() {
				System.out.println("h() a=" + a + " b=" + b + " c=" + c);
				g();
				f();
			}
		}
	}

	public static void main(String[] args) {
		A a = new A(1);
		A.B b = a.new B(2);
		A.B.C c = b.new C(3);
		c.h();

		A a2 = new A(11);
		A.B b2 = a2.new B(22);
		A.B.C c2 = b2.new C(33);
		c2.h();

		A a3 = new A(111);
		A.B b3 = a.new B(222);
		A.B.C c3 = b2.new C(333);
		a3.f();
		b3.g();
		c3.h();
	}
}